import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { ResFileConst } from "../../resource/ResFileConst";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { ObjCreate } from "../common/ObjCreate";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { TextAlign } from "../../../../flashx/textLayout/formats/TextAlign";
import { Language } from "../../../../extend/language/Language";
import { BaseItemNormal } from "../common/item/BaseItemNormal";
import { SGroupBuy } from "../../../../Message/Public/SGroupBuy";
import { ItemData } from "../../resource/info/ItemData";
import { ShopConfig } from "../../resource/ShopConfig";
import { EPrictUnit } from "../../../../Message/Public/EPrictUnit";
import { ScaleBitmap } from "../../../../com/mui/display/ScaleBitmap";
type int = number;
//class TeamBuyItem
    
    export  class TeamBuyItem /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.initView();
            this.addEventListener(flash.events.MouseEvent.MOUSE_OVER, this.overfun);
            this.addEventListener(flash.events.MouseEvent.MOUSE_OUT, this.outfun);
            LoaderHelp.addResCallBack(ResFileConst.TeamBuy, this.loadSourceFinish);
            return;
        }

        /* internal  */loadSourceFinish(): void
        {
            this.selectIcon.bitmapData = GlobalClass.getBitmapData(ImagesConst.TeamBuy_selectIcon);
            return;
        }

        public set hasJoin(arg1: Boolean)
        {
            this._hasJoin = arg1;
            this.selectIcon.visible = this._hasJoin;
            return;
        }

        public get hasJoin(): Boolean
        {
            return this._hasJoin;
        }

        /* internal  */overfun(arg1: Object /* flash.events.Event */): void
        {
            if (this._select) 
            {
                return;
            }
            this.bg.filters = [FilterConst.yellowGlowFilter];
            return;
        }

        /* internal  */outfun(arg1: Object /* flash.events.Event */): void
        {
            if (this._select) 
            {
                return;
            }
            this.bg.filters = null;
            return;
        }

        public set select(arg1: Boolean)
        {
            this._select = arg1;
            if (this._select) 
            {
                this.bg.filters = [FilterConst.yellowGlowFilter];
            }
            else 
            {
                this.bg.filters = null;
            }
            return;
        }

        public get select(): Boolean
        {
            return this._select;
        }

        /* internal  */initView(): void
        {
            this.bg = ObjCreate.createBg(0, 0, 125, 168, this, ImagesConst.RechargeBottom);
            var loc1=GlobalStyle.textFormat6;
            loc1.align = TextAlign.CENTER;
            this.title = ObjCreate.createTextField("", 28, 5, 68, 16, this, loc1);
            ObjCreate.createTextField(Language.getString(85039), 5, 123, 91, 20, this);
            ObjCreate.createTextField(Language.getString(85040), 5, 145, 91, 20, this, GlobalStyle.textFormat5);
            var loc2=GlobalStyle.textFormat1;
            loc2.align = TextAlign.RIGHT;
            this.oldPriceTF = ObjCreate.createTextField("199", 71, 123, 30, 20, this, loc2);
            var loc3=GlobalStyle.textFormat5;
            loc3.align = TextAlign.RIGHT;
            this.curPriceTF = ObjCreate.createTextField("99", 71, 145, 30, 20, this, loc3);
            this.moneyIcon1 = ObjCreate.createBitmap(ImagesConst.Yuanbao_small, 100, 124, this);
            this.moneyIcon2 = ObjCreate.createBitmap(ImagesConst.Yuanbao_small, 100, 145, this);
            ObjCreate.setObjAttri(this.drawLineSp(), 80, 128, -1, -1, this);
            ObjCreate.createBg(3, 24, 120, 20, this, ImagesConst.FightingStrgBg);
            this._nameTxt = ObjCreate.createTextField("", 3, 26, 120, 26, this, loc1);
            this._baseItem = new BaseItemNormal();
            this._baseItem.setSize(64, 64);
            this._baseItem.isDragAble = false;
            this._baseItem.isDropAble = false;
            ObjCreate.setObjAttri(this._baseItem, 30, 52, -1, -1, this);
            this.selectIcon = new Object /* flash.display.Bitmap */();
            ObjCreate.setObjAttri(this.selectIcon, 83, -21, -1, -1, this);
            this.selectIcon.visible = false;
            return;
        }

        public updateData(arg1: SGroupBuy, arg2: int): void
        {
            var loc2=null;
            var loc3=null;
            var loc4=null;
            var loc5=null;
            this.data = arg1;
            this.itemIdex = arg2;
            this.priceList = new Array<any>();
            var loc1=arg1.priceList;
            var loc6=0;
            var loc7=loc1;
            for (loc2 in loc7) 
            {
                loc5 = {"personNum": loc2, "ybNum": loc1[loc2]};
                this.priceList.push(loc5);
            }
            this.priceList.sortOn("personNum", Array.NUMERIC);
            this.title.text = Language.getString(85041) + (arg2 + 1);
            loc3 = new ItemData(int(arg1.itemCode));
            this._baseItem.itemData = loc3;
            this.giftHtmlName = loc6 = loc3.itemInfo.htmlName;
            this._nameTxt.htmlText = loc6;
            loc4 = ShopConfig.instance.getShopItemInfoByCode(arg1.itemCode, 2031);
            this.oldPrice = loc4.tshopSell.price;
            this.curPrice = arg1.price;
            this.oldPriceTF.text = "" + this.oldPrice;
            this.curPriceTF.text = "" + this.curPrice;
            if (this.data.unit != EPrictUnit._EPriceUnitGold) 
            {
                this.moneyIcon2.bitmapData = loc6 = GlobalClass.getBitmapData(ImagesConst.Tongqian_small);
                this.moneyIcon1.bitmapData = loc6;
            }
            else 
            {
                this.moneyIcon2.bitmapData = loc6 = GlobalClass.getBitmapData(ImagesConst.Yuanbao_small);
                this.moneyIcon1.bitmapData = loc6;
            }
            return;
        }

        /* internal  */drawLineSp(): Object /* flash.display.Sprite */
        {
            var loc1=new Object /* flash.display.Sprite */();
            loc1.graphics.clear();
            loc1.graphics.lineStyle(1.5, 16711680);
            loc1.graphics.moveTo(0, 0);
            loc1.graphics.lineTo(20, 7);
            return loc1;
        }

        /* internal */ /* var */title: Object /* flash.text.TextField */;

        /* internal */ /* var */oldPriceTF: Object /* flash.text.TextField */;

        /* internal */ /* var */curPriceTF: Object /* flash.text.TextField */;

        protected /* var */_baseItem: BaseItemNormal;

        protected /* var */_nameTxt: Object /* flash.text.TextField */;

        public /* var */data: SGroupBuy;

        public /* var */priceList: Array<any>;

        public /* var */oldPrice: int;

        public /* var */curPrice: int;

        /* internal */ /* var */_select: Boolean=false;

        public /* var */itemIdex: int=0;

        /* internal */ /* var */bg: ScaleBitmap;

        /* internal */ /* var */_hasJoin: Boolean=false;

        public /* var */firstBuyPirce: int=0;

        public /* var */giftHtmlName: string;

        /* internal */ /* var */selectIcon: Object /* flash.display.Bitmap */;

        /* internal */ /* var */moneyIcon1: Object /* flash.display.Bitmap */;

        /* internal */ /* var */moneyIcon2: Object /* flash.display.Bitmap */;
    }
